package com.example.questionbase.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.example.questionbase.handler.KeywordTypeHandler;
import lombok.Data;

/**
 * @TableName question
 */
@TableName(value = "question", autoResultMap = true)
@Data
public class Question implements Serializable {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @TableField("content")
    private String content;

    @TableField(value = "keyword", typeHandler = KeywordTypeHandler.class)
    private List<String> keyword;

    @TableField("frequency")
    private Integer frequency;

    @TableField("last_viewed_time")
    private Date lastViewedTime;

    private static final long serialVersionUID = 1L;

    public Question() {
    }

    public Question(String content, List<String> keyword, Integer frequency) {
        this.content = content;
        this.keyword = keyword;
        this.frequency = frequency;
    }

    public void addFrequency() {
        this.frequency = this.frequency + 1;
    }

}